﻿using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using NL.ADA.Logging;

namespace NL.ADA.ConfigProxy
{
    public class KeyValueTypeCollection<T> : Dictionary<string, KeyValueType>
    {
        private AdaLogger _logger;
        public KeyValueTypeCollection()
        {
            _logger = new AdaLogger();
        }
        public T this[string name]
        {
            
            get
            {
                
                T result;
                _logger.Log(LogEvent.EnterEvent);
                if (name == null) throw new ArgumentNullException("key");
                var tempResult = base[name];
                _logger.Log(LogEvent.InfoEvent, "name: " + name +"tempResult: " + tempResult);
                _logger.Log(LogEvent.LeaveEvent);
                result = (T)Convert.ChangeType(tempResult.Value, tempResult.Type);
                _logger.Log(LogEvent.InfoEvent,"result: " + result.ToString());
                return result;
                
            }
        }

    }
    public class KeyValueTypeCollection : NameValueCollection
    {
        public KeyValueTypeCollection()
        {
        }
        public string this[string name]
        {
            get
            {
                if (name == null) throw new ArgumentNullException("key");
                return base[name];
            }
        }

    }

}
